package org.yx.service.sbas.view_workshop;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SbasWspDef;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询车间信息
 * @author zxw
 * @since 2018/04/14
**/
public class SbasViewWorkshopService extends BaseService {
	public SbasViewWorkshopOut viewWorkshop(SbasViewWorkshopIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		query.addFilter("status", "<>", 'D');
		if (!StrUtil.isBlank(in.getShopCode())) {
			query.addFilter("shopCode", in.getShopCode());
		}
		if (!StrUtil.isBlank(in.getShopType())) {
			query.addFilter("shopType", in.getShopType());
		}

		Page<SbasWspDef> shopPage = selectPage(SbasWspDef.class, query);

		SbasViewWorkshopOut out = new SbasViewWorkshopOut();
		out.setShopList(shopPage.getList());
		out.setTotalSize(shopPage.getTotalSize());

		return out;
	}
}